package com.globallogic.learning.kozius.actor;


/**
 * Class describes the administrative personnel actor.
 * <p/>
 * Created by sergii.koziumynskyi on 2/4/14.
 */

import com.globallogic.learning.kozius.res.Permissions;

public final class Admin extends People {
    public Admin(String firstName, String lastName, int yearOfBirth, int monthOfBirth, int dayOfBirth, String placeOfBirth, Permissions permission) {
        super(firstName, lastName, yearOfBirth, monthOfBirth, dayOfBirth, placeOfBirth);
        this.permission = permission;
    }

    public Admin(String firstName, String lastName, Permissions permission) {
        super(firstName, lastName);
        this.permission = permission;
    }

    public Admin() {
    }

    public int getId() {
        return id;
    }

    public Permissions getPermission() {
        return permission;
    }

    public void setPermission(Permissions permission) {
        this.permission = permission;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Admin)) return false;
        if (!super.equals(o)) return false;

        Admin admin = (Admin) o;

        if (id != admin.id) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + id;
        result = 31 * result + (permission != null ? permission.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Admin{" +
                "id=" + id +
                ", permission=" + permission +
                "} " + super.toString();
    }

    private int id;
    private Permissions permission = Permissions.NO_ACCESS;
    private static int nextId = 300000000;  // 3 prefix will show that it is an administer personnel

    {
        id = nextId;
        nextId++;
    }
}
